"use strict";
cc._RF.push(module, '1cc4fjp3+VAkJqZsVbPM9UW', 'DGameViewUI');
// scripts/DGameViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AssetsManager"),
    s = e("CommonHelper"),
    l = e("DFightViewUI"),
    _ = e("left_hero_item"),
    c = e("monster_hp_node"),
    d = cc._decorator,
    h = d.ccclass,
    u = d.property,
    p = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.stage_num_label = null, t.left_hero_view = null, t.monster_item_view = null, t.monster_hp_node = null, t.fight_view_ui = null, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    this.fight_view_ui = cc.find("Canvas/DFightViewUI").getComponent(l["default"]), this.showPkPlayerInfo(), this.showStageNum();
  }, t.prototype.addEvent = function () {
    this.attachEvent(n["default"].SEND_CONTINUE_D_FIGHT_GAME, this.showStageNum, this), this.attachEvent(n["default"].SEND_MONSTER_BE_HIT_NUM_SHOW_HP_INFO, this.showMonsterHp, this);
  }, t.prototype.OnClick = function (t) {
    e.prototype.OnClick.call(this, t);
    var o = t.node.name;

    switch (o) {
      case "hero_item_0":
      case "hero_item_1":
      case "hero_item_2":
        this.emitEvent(n["default"].SEND_PLAYER_STOP_MOVE_INFO);
        var a = s["default"].getNameType(o, "hero_item_");
        i.GlobalParams.MatchMyIndex = a, this.emitEvent(n["default"].SEND_PLAYER_CHOOSE_OPERATE_HERO_INDEX);
    }
  }, t.prototype.showPkPlayerInfo = function () {
    for (var e = 0; e < this.monster_item_view.childrenCount; e++) {
      var t = this.monster_item_view.children[e],
          o = t.getChildByName("player").children[0],
          a = t.getChildByName("player").children[1];
      o.getChildByName("head").getComponent(cc.Sprite).spriteFrame = r["default"].getInstance().getHeroHeadFrame("hero_" + i.GlobalParams.DarePlayerInfo[0].head), a.getChildByName("head").getComponent(cc.Sprite).spriteFrame = r["default"].getInstance().getHeroHeadFrame("hero_" + i.GlobalParams.DarePlayerInfo[1].head), o.getChildByName("my").active = !0, a.getChildByName("my").active = !1;
    }
  }, t.prototype.showStageNum = function () {
    this.monster_hp_node.active = !1;
    var e = this.fight_view_ui.monster_index;
    this.stage_num_label.string = "第" + (e + 1) + "阶段";

    for (var t = 0; t < this.monster_item_view.childrenCount; t++) {
      var o = this.monster_item_view.children[t];
      o.getChildByName("light").active = e == t, o.getChildByName("die").active = t < e;
      var a = o.getChildByName("player").children[0],
          n = o.getChildByName("player").children[1];
      a.active = i.GlobalParams.DarePlayerInfo[0].schedule == t, n.active = !1;
    }

    this.showHeroInfo();
  }, t.prototype.showHeroInfo = function () {
    for (var e = 0; e < 3; e++) {
      this.left_hero_view.children[e].getComponent(_["default"]).showLeftHeroInfo(e);
    }
  }, t.prototype.showMonsterHp = function (e, t) {
    this.monster_hp_node.active || (this.monster_hp_node.active = !0), this.monster_hp_node.getComponent(c["default"]).showMonsterHpInfo(t);
  }, oo([u(cc.Label)], t.prototype, "stage_num_label", void 0), oo([u(cc.Node)], t.prototype, "left_hero_view", void 0), oo([u(cc.Node)], t.prototype, "monster_item_view", void 0), oo([u(cc.Node)], t.prototype, "monster_hp_node", void 0), oo([h], t);
}(a["default"]);

o["default"] = p;

cc._RF.pop();